package com.shareit.ocr.util;

import com.shareit.ocr.domain.Result;
import com.shareit.ocr.enums.ResultEnum;

public class APIResultUtil {

	public static Result<Object> sucess(Object data) {
		Result<Object> result = new Result<Object>();
		result.setReturnCode(ResultEnum.SUCCESS.getCode());
		result.setErrorMessage(ResultEnum.SUCCESS.getMessage());
		result.setData(data);
		
		return result;
	}
	
	public static Result<?> error(ResultEnum em) {
		Result<?> result = new Result<Object>();
		result.setReturnCode(em.getCode());
		result.setErrorMessage(em.getMessage());
	
		return result;
	}

	public static Result<?> error(int code,String message) {
		Result<?> result = new Result<Object>();
		result.setReturnCode(code);
		result.setErrorMessage(message);

		return result;
	}
}
